package cn.new7as.cas5s.ui.easy;

import android.app.Application;
import android.provider.Settings;

import androidx.annotation.NonNull;


import cn.new7as.cas5s.BuildConfig;


import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustConfig;
import com.adjust.sdk.LogLevel;
import com.hjq.http.EasyConfig;


import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

public class AppConsant extends Application {
    private static Application sInstance;

    public static Application getsInstance() {
        return sInstance;
    }

    public static void setsInstance(Application sInstance) {
        AppConsant.sInstance = sInstance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        setApplication(this);


/*        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .readTimeout(45, TimeUnit.SECONDS)
                .writeTimeout(45, TimeUnit.SECONDS)
                .build();
        RequestServer server = new RequestServer();

        EasyConfig.with(okHttpClient)
                .setLogEnabled(BuildConfig.DEBUG)
                .setServer(server)
                .setHandler(new RequestHandler(this))
                .setRetryCount(3)
                .addHeader("appCode", "codefundbox")
                .addHeader("versionCode", BuildConfig.VERSION_CODE + "")
                .addHeader("deviceId", Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID))
                .into();*/

        sdk();
    }


    void sdk() {
        String androidId = Settings.Secure.getString(MyApplication.getInstance().getContentResolver(), Settings.Secure.ANDROID_ID);
        BaseOkHttp.overallHeader = new Parameter()
                .add("appCode", "7")
                .add("deviceId", androidId)
                .add("versionCode", BuildConfig.VERSION_CODE + "");
        String appToken = "k3ecugdge7ls";
        String environment = AdjustConfig.ENVIRONMENT_PRODUCTION;
        AdjustConfig config = new AdjustConfig(this, appToken, environment);
        config.setLogLevel(LogLevel.VERBOSE);
        Adjust.initSdk(config);
    }


    public synchronized void setApplication(@NonNull Application application) {
        sInstance = application;

    }


}
